<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="检索" prop="search">
        <el-input v-model="queryParams.search" placeholder="请输入检索信息" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item label="公司地址" prop="registerAddress">
        <el-cascader ref="cascader" v-model="queryParams.registerAddress" :options="registerAddressList" :props="props1"
          clearable></el-cascader>
      </el-form-item>
      <el-form-item label="企业性质" prop="firmNature">
        <el-select v-model="queryParams.firmNature" placeholder="请选择企业性质">
          <el-option label="国有企业" value="0"></el-option>
          <el-option label="集体所有制" value="1"></el-option>
          <el-option label="私营企业" value="2"></el-option>
          <el-option label="股份制企业" value="3"></el-option>
          <el-option label="有限合伙企业" value="4"></el-option>
          <el-option label="联营企业" value="5"></el-option>
          <el-option label="外商投资企业" value="6"></el-option>
          <el-option label="个人独资企业" value="7"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="经营范围" prop="businessScope">
        <el-cascader v-model="queryParams.businessScope" :options="firmTypeList" :props="props" clearable></el-cascader>
      </el-form-item>


      <el-form-item label="开户行" prop="brandName">
        <el-select v-model="queryParams.brandName" placeholder="请输入开户行">
          <el-option v-for="item in brandNameList" :label="item.text" :value="item.value" :key="item.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="选择日期" prop="dateTime">
        <el-date-picker clearable v-model="queryParams.dateTime" type="date" value-format="yyyy-MM-dd" placeholder="选择日期">
        </el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['wms:firm:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['wms:firm:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['wms:firm:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['wms:firm:export']">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="firmList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="公司编号" align="center" prop="firmId" width="180" />
      <el-table-column label="公司名 " align="center" prop="firmName" width="180" />
      <el-table-column label="SPI" align="center" prop="firmSip" width="180" />
      <el-table-column label="机构类型" align="center" prop="firmTypeName" width="100" />
      <el-table-column label="企业性质" align="center" prop="firmNature" width="100">
        <template slot-scope="scope">
          <el-tag effect="dark" type="danger" v-if="scope.row.firmNature == '0'">
            国有企业
          </el-tag>
          <el-tag effect="dark" type="info" v-else-if="scope.row.firmNature == '1'">
            集体所有制
          </el-tag>
          <el-tag effect="dark" type="danger" v-if="scope.row.firmNature == '2'">
            私营企业
          </el-tag>
          <el-tag effect="dark" type="info" v-else-if="scope.row.firmNature == '3'">
            股份制企业
          </el-tag>
          <el-tag effect="dark" type="danger" v-if="scope.row.firmNature == '4'">
            有限合伙企业
          </el-tag>
          <el-tag effect="dark" type="info" v-else-if="scope.row.firmNature == '5'">
            联营企业
          </el-tag>
          <el-tag effect="dark" type="danger" v-if="scope.row.firmNature == '6'">
            外商投资企业
          </el-tag>
          <el-tag effect="dark" type="info" v-else-if="scope.row.firmNature == '7'">
            个人独资企业
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="成立日期" align="center" prop="firmCreate" width="120" />
      <el-table-column label="法人" align="center" prop="firmBy" />
      <el-table-column label="法人身份证" align="center" prop="byIdcard" width="180" />
      <el-table-column label="经营范围" align="center" prop="businessScopeName" />
      <el-table-column label="开户行" align="center" prop="brandName" width="180" />
      <el-table-column label="注册资本" align="center" prop="registerCapital" />
      <el-table-column label="审核状态" align="center" prop="firmStatus" width="100">
        <template slot-scope="scope">
          <el-tag effect="dark" type="danger" v-if="scope.row.firmStatus == '5'">
            待审核
          </el-tag>
          <el-tag effect="dark" type="info" v-else-if="scope.row.firmStatus == '6'">
            驳回
          </el-tag>
          <el-tag effect="dark" type="danger" v-if="scope.row.firmStatus == '4'">
            中标
          </el-tag>
          <el-tag effect="dark" type="info" v-else-if="scope.row.firmStatus == '2'">
            已审核
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="公司状态" align="center" prop="status">
        <template slot-scope="scope">
          <el-switch v-model="scope.row.status" active-value="0" inactive-value="1"
            @change="handleStatusChange(scope.row)">
          </el-switch>
        </template>
      </el-table-column>
      <el-table-column label="营业执照有效期" align="center" prop="businessEnd" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.businessEnd, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['wms:firm:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-message-solid" v-if="scope.row.firmStatus == '5'"
            @click="handleFlag(scope.row)" v-hasPermi="['wms:firm:edit']">审核</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['wms:firm:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改公司投标信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="招标项目" prop="markId">
          <el-select v-model="form.markId" placeholder="请选择招标项目" :disabled="form.id != null">
            <el-option v-for="item in markUseList" :label="item.markName" :key="item.id" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="公司编号" prop="firmId" v-if="form.id != null">
          <el-input v-model="form.firmId" placeholder="请输入公司编号" :disabled="true" />
        </el-form-item>
        <el-form-item label="公司名 " prop="firmName" v-if="form.id != null">
          <el-input v-model="form.firmName" placeholder="请输入公司名 " :disabled="true" />
        </el-form-item>
        <el-form-item label="SPI" prop="firmSip" v-if="form.id != null">
          <el-input v-model="form.firmSip" placeholder="请输入统一社会信用代码" :disabled="true" />
        </el-form-item>
        <el-form-item label="注册地址" prop="registerAddress" v-if="form.id != null">
          <!-- <el-cascader :disabled="form.id != null" ref="cascader" v-model="form.registerAddress"
            :options="registerAddressList" :props="props1" clearable></el-cascader> -->
          <el-input v-model="form.registerAddress" :disabled="true" />
        </el-form-item>
        <el-form-item label="企业性质" prop="firmNature">
          <el-select v-model="form.firmNature" placeholder="请选择企业性质">
            <el-option label="国有企业" value="0"></el-option>
            <el-option label="集体所有制" value="1"></el-option>
            <el-option label="私营企业" value="2"></el-option>
            <el-option label="股份制企业" value="3"></el-option>
            <el-option label="有限合伙企业" value="4"></el-option>
            <el-option label="联营企业" value="5"></el-option>
            <el-option label="外商投资企业" value="6"></el-option>
            <el-option label="个人独资企业" value="7"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="成立日期" prop="firmCreate" v-if="form.id != null">
          <el-date-picker clearable v-model="form.firmCreate" type="date" value-format="yyyy-MM-dd" placeholder="选择日期"
            :disabled="true">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="法人" prop="firmBy" v-if="form.id != null">
          <el-input v-model="form.firmBy" placeholder="请输入法人/负责人" :disabled="true" />
        </el-form-item>
        <el-form-item label="联系地址" prop="firmAddress" v-if="form.id != null">
          <el-input v-model="form.firmAddress" placeholder="请输入单位联系地址" :disabled="true" />
        </el-form-item>
        <el-form-item label="经营范围" prop="businessScopeList">
          <el-cascader ref="cascader1" @visible-change="handleChange" v-model="form.businessScopeList"
            :options="firmTypeList" :props="props" clearable></el-cascader>
        </el-form-item>
        <el-form-item label="营业执照扫描件" prop="businessLicense">
          <ImageUpload :limit=1 :fileSize="10" :ImgUrl="'/wms/firm/BizLicenseOCR'" @input="uploadSuccess"
            :value="form.businessLicense">
          </ImageUpload>
        </el-form-item>
        <el-form-item label="法人身份证扫描件" prop="byIdcardLicense">
          <ImageUpload :limit=1 :fileSize="10" @input="uploadSuccess1" :ImgUrl="'/wms/firm/IDCardOCR'"
            :value="form.byIdcardLicense">
          </ImageUpload>
        </el-form-item>
        <el-form-item label="开户信息" prop="brandUrl">
          <ImageUpload :limit=1 :fileSize="10" @input="uploadSuccess2" :ImgUrl="'/wms/firm/BankCardOCR'"
            :value="form.brandUrl">
          </ImageUpload>
        </el-form-item>
        <el-form-item label="开户行" prop="brandName" v-if="form.id != null">
          <el-input v-model="form.brandName" placeholder="请输入开户行" :disabled="true" />
          <!-- <el-select v-model="form.brandName" placeholder="请输入开户行">
            <el-option v-for="item in brandNameList" :label="item.text" :value="item.value" :key="item.value"
              :disabled="true"></el-option>
          </el-select> -->
        </el-form-item>
        <el-form-item label="开户账号" prop="brandAccount" v-if="form.id != null">
          <el-input v-model="form.brandAccount" placeholder="请输入开户账号" :disabled="true" />
        </el-form-item>
        <el-form-item label="开户地址" prop="brandAddress" v-if="form.id != null">
          <el-input v-model="form.brandAddress" placeholder="请输入开户地址" :disabled="true" />
        </el-form-item>
        <el-form-item label="基本户存款信息证" prop="brandInfo">
          <ImageUpload :limit=1 :fileSize="10" @input="uploadSuccess3" :ImgUrl="'/wms/firm/GeneralBasicOCR'"
            :value="form.brandInfo">
          </ImageUpload>
        </el-form-item>
        <el-form-item label="注册资本" prop="registerCapital">
          <el-input-number placeholder="请输入注册资本" size="small" v-model="form.registerCapital" :min="0" :max="99999999"
            :disabled="this.form.id != null"></el-input-number>
        </el-form-item>
        <el-form-item label="实缴资本" prop="capitalNum">
          <el-input-number :disabled="this.form.id != null" placeholder="请输入实缴资本" size="small" v-model="form.capitalNum"
            :min="0" :max="form.capitalNum > form.registerCapital ? form.registerCapital : 99999999">
          </el-input-number>
        </el-form-item>


        <el-form-item label="营业执照有效期" prop="businessEnd" v-if="form.id != null">
          <el-date-picker :disabled="true" clearable v-model="form.businessEnd" type="date" value-format="yyyy-MM-dd"
            placeholder="请选择营业执照有效期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="公司简介">
          <editor v-model="form.firmRemark" :min-height="192" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" v-if="flag == 1" @click="submitForm2">审核通过</el-button>
        <el-button type="danger" v-if="flag == 1" @click="submitForm1">驳 回</el-button>
        <el-button type="primary" v-if="flag == 0" @click="submitForm">提 交</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { updatMarkStatus, changeFirmStatus, listMarkUse, getRegisterAddressList, listFirm, getFirm, delFirm, addFirm, updateFirm } from "@/api/wms/firm";
export default {
  name: "Firm",
  data () {
    return {
      // 标注提交状态 0 提交 2 待开标 6驳回 
      flag: 0,
      // 可用招标信息
      markUseList: [],
      registerAddressList: [],
      props1: {
        children: 'children',
        label: 'name',
        value: "code",
      },
      props: {
        children: 'children',
        label: 'name',
        value: "id",
      },
      firmTypeList: [{
        "id": 1001,
        "name": "IT服务",
        "children": [
          {
            "id": 1001000,
            "name": "计算机软件/硬件/信息服务",

          },
          {
            "id": 1001001,
            "name": "互联网和相关服务",
          },
          {
            "id": 1001002,
            "name": "其他",
          }
        ],
      },
      {
        "id": 1002,
        "name": "制造业",
        "children": [
          {
            "id": 1002000,
            "name": "机械/电子",
          },
          {
            "id": 1003000,
            "name": "服装/纺织",
          },
          {
            "id": 1002002,
            "name": "汽车",
          },
          {
            "id": 1002005,
            "name": "金属制品",
          },
          {
            "id": 1003002,
            "name": "食品/饮料",
          },
          {
            "id": 1003003,
            "name": "家具/家纺",
          },
          {
            "id": 1002001,
            "name": "重工制造",
          },
          {
            "id": 1003005,
            "name": "家电/数码",
          },
          {
            "id": 1002004,
            "name": "橡胶/塑料",
          },
          {
            "id": 1003004,
            "name": "日用品/化妆品",
          },
          {
            "id": 1002006,
            "name": "化学原料制品",
          },
          {
            "id": 1003007,
            "name": "文教/工美/体育/娱乐用品",
          },
          {
            "id": 1003006,
            "name": "烟酒/茶",
          },
          {
            "id": 1002007,
            "name": "非金属矿物",
          },
          {
            "id": 1002003,
            "name": "其他",
          }
        ],
      },
      {
        "id": 1003,
        "name": "批发/零售",
        "children": [
          {
            "id": 1003008,
            "name": "批发",
          },
          {
            "id": 1003010,
            "name": "零售",

          },
          {
            "id": 1003001,
            "name": "超市/便利店/百货商场",

          },
          {
            "id": 1003011,
            "name": "进出口",

          },
          {
            "id": 1003009,
            "name": "其他",

          }
        ],

      },
      {
        "id": 1004,
        "name": "生活服务",
        "children": [
          {
            "id": 1004001,
            "name": "餐饮",

          },
          {
            "id": 1004004,
            "name": "居民服务",

          },
          {
            "id": 1004002,
            "name": "租赁和商务服务",

          },
          {
            "id": 1004000,
            "name": "酒店/住宿",

          },
          {
            "id": 1004003,
            "name": "其他",

          }
        ],

      },
      {
        "id": 1005,
        "name": "文化/体育/娱乐业",
        "children": [
          {
            "id": 1005001,
            "name": "文化/体育",

          },
          {
            "id": 1005002,
            "name": "娱乐/旅游",

          },
          {
            "id": 1005000,
            "name": "新闻传媒",

          },
          {
            "id": 1005003,
            "name": "其他",

          }
        ],

      },
      {
        "id": 1006,
        "name": "建筑/房地产",
        "children": [
          {
            "id": 1006001,
            "name": "建筑业",

          },
          {
            "id": 1006002,
            "name": "建材装修",

          },
          {
            "id": 1006000,
            "name": "房地产",

          },
          {
            "id": 1006003,
            "name": "其他",

          }
        ],

      },
      {
        "id": 1007,
        "name": "教育",
        "children": [
          {
            "id": 1007000,
            "name": "学前教育",
          },
          {
            "id": 1007001,
            "name": "初中等教育",
          },
          {
            "id": 1007002,
            "name": "高等教育",
          },
          {
            "id": 1007003,
            "name": "培训机构",
          },
          {
            "id": 1007004,
            "name": "其他",

          }
        ],
      },
      {
        "id": 1008,
        "name": "运输/物流/仓储",
        "children": [
          {
            "id": 1008003,
            "name": "物流/仓储",

          },
          {
            "id": 1008000,
            "name": "道路/铁路运输",

          },
          {
            "id": 1008004,
            "name": "邮政/快递",

          },
          {
            "id": 1008001,
            "name": "航空运输",

          },
          {
            "id": 1008002,
            "name": "水上运输",

          },
          {
            "id": 1008005,
            "name": "其他",

          }
        ],
      },
      {
        "id": 1009,
        "name": "医疗",
        "children": [
          {
            "id": 1009000,
            "name": "医院/医疗机构",

          },
          {
            "id": 1009003,
            "name": "医疗器械",

          },
          {
            "id": 1009001,
            "name": "医药制造",

          },
          {
            "id": 1009002,
            "name": "医药流通",

          },
          {
            "id": 1009004,
            "name": "其他",

          }
        ],
      },
      {
        "id": 1010,
        "name": "政府",
        "children": [
          {
            "id": 1010000,
            "name": "党政机关",

          },
          {
            "id": 1010001,
            "name": "国家权力/行政机构",

          },
          {
            "id": 1010002,
            "name": "检察院/法院/公安",

          },
          {
            "id": 1010003,
            "name": "民政/人社/交通/卫生",

          },
          {
            "id": 1010004,
            "name": "发改委/经信委/商务局/统计局",

          },
          {
            "id": 1010005,
            "name": "国土/规划",

          },
          {
            "id": 1010006,
            "name": "税务/海关/工商/环保/物价/药品",

          },
          {
            "id": 1010007,
            "name": "政协/民主党派",

          },
          {
            "id": 1010008,
            "name": "地方政府",

          },
          {
            "id": 1010009,
            "name": "其他",

          }
        ],

      },
      {
        "id": 1011,
        "name": "金融",
        "children": [
          {
            "id": 1011000,
            "name": "保险",

          },
          {
            "id": 1011001,
            "name": "银行",

          },
          {
            "id": 1011002,
            "name": "证券/投资/基金",

          },
          {
            "id": 1011003,
            "name": "其他",

          }
        ],

      },
      {
        "id": 1012,
        "name": "能源/采矿",
        "children": [
          {
            "id": 1014003,
            "name": "电力/热力/燃气/水供应业",

          },
          {
            "id": 1012003,
            "name": "石油/天然气",

          },
          {
            "id": 1012002,
            "name": "煤炭",

          },
          {
            "id": 1012001,
            "name": "有色金属",

          },
          {
            "id": 1012000,
            "name": "钢铁",

          },
          {
            "id": 1012004,
            "name": "其他",

          }
        ],

      },
      {
        "id": 1013,
        "name": "农林渔牧",
        "children": [
          {
            "id": 1013000,
            "name": "农林渔牧",

          }
        ],

      },
      {
        "id": 1014,
        "name": "其他行业",
        "children": [
          {
            "id": 1014000,
            "name": "科学研究和技术服务业",

          },
          {
            "id": 1014002,
            "name": "社会组织",

          },
          {
            "id": 1014001,
            "name": "水利和环境管理",

          },
          {
            "id": 1014004,
            "name": "国际组织",

          },
          {
            "id": 1014005,
            "name": "其他",

          }
        ],
      }
      ],
      // 银行信息
      brandNameList:
        [
          {
            value: 'CDB',
            text: '国家开发银行'
          },
          {
            value: 'ICBC',
            text: '中国工商银行'
          },
          {
            value: 'ABC',
            text: '中国农业银行'
          },
          {
            value: 'BOC',
            text: '中国银行'
          },
          {
            value: 'CCB',
            text: '中国建设银行'
          },
          {
            value: 'PSBC',
            text: '中国邮政储蓄银行'
          },
          {
            value: 'COMM',
            text: '交通银行'
          },
          {
            value: 'CMB',
            text: '招商银行'
          },
          {
            value: 'SPDB',
            text: '上海浦东发展银行'
          },
          {
            value: 'CIB',
            text: '兴业银行'
          },
          {
            value: 'HXBANK',
            text: '华夏银行'
          },
          {
            value: 'GDB',
            text: '广东发展银行'
          },
          {
            value: 'CMBC',
            text: '中国民生银行'
          },
          {
            value: 'CITIC',
            text: '中信银行'
          },
          {
            value: 'CEB',
            text: '中国光大银行'
          },
          {
            value: 'EGBANK',
            text: '恒丰银行'
          },
          {
            value: 'CZBANK',
            text: '浙商银行'
          },
          {
            value: 'BOHAIB',
            text: '渤海银行'
          },
          {
            value: 'SPABANK',
            text: '平安银行'
          },
          {
            value: 'NHQS',
            text: '农信银清算中心'
          },
          {
            value: 'CBBQS',
            text: '城市商业银行资金清算中心'
          }
        ],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 公司投标信息表格数据
      firmList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {},


      // 表单校验
      rules: {

        markId: [
          { required: true, message: "招标项目", trigger: "change" }
        ],
        firmNature: [
          { required: true, message: "企业性质不能为空", trigger: "change" }
        ],
        businessScopeList: [
          { required: true, message: "经营范围", trigger: "change" }
        ],
        businessLicense: [
          { required: true, message: "营业执照扫描件", trigger: "blur" }
        ],
        byIdcardLicense: [
          { required: true, message: "法人身份证扫描件", trigger: "change" }
        ],
        // brandUrl: [
        //   { required: true, message: "开户信息", trigger: "change" }
        // ],
        brandInfo: [
          { required: true, message: "基本户存款信息证", trigger: "change" }
        ],
        registerCapital: [
          { required: true, message: "注册资本", trigger: "blur" }
        ],
        capitalNum: [
          { required: true, message: "实缴资本", trigger: "change" }
        ],
        businessEnd: [
          { required: true, message: "营业执照有效期", trigger: "change" }
        ],
      }
    };
  },
  created () {
    this.getList();
    this.getRegisterAddressListInfo()
  },
  methods: {
    // 获取可用招标信息
    getListMarkUse () {
      listMarkUse().then(res => {
        this.markUseList = res.data
      })
    },
    handleChange (val) {
      if (!val) {
        let nodesInfo = this.$refs['cascader1'].getCheckedNodes()
        console.log('nodesInfo>>>>>', nodesInfo)
        this.form.firmTypeName = nodesInfo[nodesInfo.length - 1].parent.label
        this.form.businessScopeName = nodesInfo[nodesInfo.length - 1].label
      }
    },
    // 修改公司状态
    handleStatusChange (row) {
      let text = row.status === "0" ? "启用" : "停用";
      this.$modal.confirm('确认要"' + text + row.firmName + '"吗？').then(function () {
        return changeFirmStatus(row.id, row.status);
      }).then(() => {
        this.$modal.msgSuccess(text + "成功");
        this.getList()
      }).catch(function () {
        row.status = row.status === "0" ? "1" : "0";
      });
    },
    // 开户信息扫描件
    uploadSuccess2 (strs, recognize) {
      console.log(strs);
      console.log(recognize);
      this.form.brandUrl = strs;
      this.form.bankCardOCRVO = recognize;
    },
    // 开户许可扫描件
    uploadSuccess3 (strs, recognize) {
      console.log(strs);
      console.log(recognize);
      this.form.brandInfo = strs;
      this.form.genralBasicOCRVO = recognize;
    },
    // 营业执照扫描件
    uploadSuccess (strs, recognize) {
      console.log(strs);
      console.log(recognize);
      this.form.businessLicense = strs;
      this.form.bizLicenseOCRVO = recognize;
    },
    // 法人身份证扫描件
    uploadSuccess1 (strs, recognize) {
      console.log(strs);
      console.log(recognize);

      this.form.byIdcardLicense = strs;
      this.form.idCardResultVO = recognize;
    },

    // 获取所有地址
    getRegisterAddressListInfo () {
      getRegisterAddressList().then(res => {
        this.registerAddressList = res
      })
    },
    // 格式化数据，递归将空的children置为undefined
    formatData (data) {
      for (var i = 0; i < data.length; i++) {
        if (data[i].children.length < 1) {
          // children若为空数组，则将children设为undefined
          data[i].children = undefined;
        } else {
          // children若不为空数组，则继续 递归调用 本方法
          this.formatData(data[i].children)
        }
      }
      return data;
    },
    /** 查询公司投标信息列表 */
    getList () {
      this.loading = true;
      listFirm(this.queryParams).then(response => {
        this.firmList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel () {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset () {
      this.form = {

      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery () {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery () {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange (selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd () {
      this.getListMarkUse();
      this.reset();
      this.open = true;
      this.title = "添加公司投标信息";
    },
    // 审核按钮
    handleFlag (row) {
      this.flag = 1
      this.handleUpdate(row)
    },
    /** 修改按钮操作 */
    handleUpdate (row) {
      this.getListMarkUse();
      this.reset();
      const id = row.id || this.ids
      console.log(id);
      console.log(row.markId);
      getFirm(id, row.markId).then(response => {
        this.form = response.data;
        this.open = true;
        if (this.flag != 1) {
          this.title = "修改公司投标信息";

        } else {
          this.title = "审核投标信息";
        }

      });
    },
    // 驳回
    submitForm1 () {
      this.flag = 6
      var firmStatus = this.flag
      this.handleupdatMarkStatus(this.form.id, this.form.markId, firmStatus);
    },
    handleupdatMarkStatus (firmId, markId, firmStatus) {
      updatMarkStatus(firmId, markId, firmStatus).then(res => {
        this.$modal.msgSuccess(res.msg);
        this.open = false;
        this.flag = 0;
        this.getList();
      })
    },
    // 审核通过
    submitForm2 () {
      this.flag = 2
      var firmStatus = this.flag
      this.handleupdatMarkStatus(this.form.id, this.form.markId, this.flag);
    },
    /** 提交按钮 */
    submitForm () {
      this.$refs["form"].validate(valid => {
        if (valid) {
          addFirm(this.form).then(response => {
            this.$modal.msgSuccess(response.msg);
            this.open = false;
            this.getList();
          });
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete (row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除公司投标信息编号为"' + ids + '"的数据项？').then(function () {
        return delFirm(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport () {
      this.download('wms/firm/export', {
        ...this.queryParams
      }, `投标资料_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
